<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/sys/include/taglib.jsp"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<%@ include file="/WEB-INF/adminui/include/css.jsp" %>
<title>物品列表</title>
</head>
<body class="gray-bg">
<div class="wrapper wrapper-content ">
	<div class="row">
		<div class="col-sm-12">
			<div class="ibox">
				<div class="ibox-body">
					<div class="fixed-table-toolbar">
						<div id="toolbar" class="columns pull-left">
							<qx:perm code="res_ADD"> 
							<button type="button" class="btn btn-primary" onclick="add()">
								<i class="fa fa-plus hidden" aria-hidden="true"></i>添加
							</button>
							</qx:perm>
							<qx:perm code="res_DEL">
							<button type="button" class="btn btn-danger multi" onclick="del()">
								<i class="fa fa-trash hidden" aria-hidden="true"></i>删除
							</button>
							</qx:perm>
						</div>
						<div class="columns pull-right">
							<button class="btn btn-success" onclick="UiList.loadTable()">查询</button>
						</div>
						<div class="columns pull-right col-md-2 nopadding">
							<input id="searchName" type="text" class="form-control" placeholder="按名称查询">
						</div>
						<div class="columns pull-right col-md-2 nopadding" style="width:125px;margin-right:5px;">
							<select id="typeid" class="form-control">
								<option value="">--选择类别--</option>
								<c:forEach items="${types}" var="type">
								<option value="${type.typeid}">${type.typeName}</option>
								</c:forEach>
							</select>
						</div>
					</div>
					<table id="dataTable" data-mobile-responsive="true">
					</table>
				</div>
			</div>
		</div>
	</div>
</div>
<%@ include file="/WEB-INF/adminui/include/script.jsp" %>
<script type="text/javascript">
$(function(){
	UiList.render({
		tableConfig:{
			url: "${path}/res/listdata.json",
			idfield: 'resid',
			columns: [
				{checkbox : true},
				{field : 'typeName', title : '类别'},
				{field : 'resDm', title : '物品代码'},
				{field : 'resTm', title : '物品条码'},
				{field : 'resName', title : '物品名称'},
				{field : 'pinyin', title : '拼音助记符'},
				{field : 'model', title : '型号'},
				{field : 'unit', title : '单位'},
				{field : 'sccj', title : '生产单位'},
				/* {field : 'stockMax', title : '库存上限'},
				{field : 'stockMin', title : '库存下限'}, */
				{field : 'inPrice', title : '默认入库价格'},
				{field : 'outPrice', title : '默认出库价格'},
				{field : 'middlePrice', title : '库存平均价格'},
				{field : 'resid', title : '操作', align : 'center', formatter : function(value, row, index) {
					var s = '';
					<qx:perm code="res_EDIT">
					s += '<a class="btn btn-primary btn-sm" href="javascript:;" title="修改" onclick="edit(\''+value+'\')">修改</a> ';
					</qx:perm>
					<qx:perm code="res_VIEW">
					s += '  <a class="btn btn-primary btn-sm" href="javascript:;" title="查看" onclick="view(\''+value+'\')">查看</a> ';
					</qx:perm>
					return s;
				}}
			]
		},
		tableParams: function(){//搜索条件
			return {searchname: $("#searchName").val(),typeid: $("#typeid").val()};
		}
	});
	
});

function add(){
	UiList.open('${path}/res/add.do', '添加信息', {full:true});
}
function del(){
	UiList.dialog('${path}/res/delete.json', '您确定要删除选中的信息吗？', '删除信息成功.');
}
function edit(id){
	UiList.open('${path}/res/edit.do?resid='+id, '修改信息', {full:true});
}
function view(id){
	UiList.open('${path}/res/view.do?resid='+id, '查看信息', {full:true});
}
</script>
</body>
</html>